<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author LYS
-->
<template>
  <BasicDrawer
    v-bind="$attrs"
    :showFooter="true"
    :okAuth="'cardd:ddrw:carddYcddrw:edit'"
    @register="registerDrawer"
    @ok="handleSubmit"
    width="100%"
  >
    <template #title>
      <Icon :icon="getTitle.icon" class="m-1 pr-1" />
      <span> {{ getTitle.value }} </span>
    </template>
    <template #footer>
      <a-button
        v-if="hasPermission('cardd:ddrw:carddYcddrw:generate')"
        type="primary"
        class="purple"
        @click="handleGenerate"
        >生成明细
      </a-button>
      <a-button type="primary" @click="closeDrawer">关闭</a-button>
      <a-button type="primary" class="purple" @click="handleSubmit('0', '')">暂存</a-button>
      <a-button type="primary" v-if="record.showBackBtn" @click="openBackForm" danger
        >退回
      </a-button>
      <a-button type="primary" v-if="record.showRwqrBtn" @click="handleSubmit('1', '2')"
        >任务确认
      </a-button>
      <a-button type="primary" v-if="record.showQxqrBtn" @click="handleSubmit('1', '1')" danger
        >取消确认
      </a-button>
      <a-button type="primary" v-if="record.showCjwcBtn" @click="handleSubmit('1', '3')"
        >车检完成
      </a-button>
      <a-button type="primary" v-if="record.showBcrwBtn" @click="handleSubmit('1', '6')"
        >提交任务
      </a-button>

      <a-button type="primary" v-if="record.showDdscdBtn" @click="handleSubmit('1', '5')"
        >到达上车点
      </a-button>
      <a-button type="primary" v-if="record.showTjrw1Btn" @click="handleSubmit('1', '6')"
        >提交任务
      </a-button>

      <a-button
        type="primary"
        v-if="record.showRwwcBtn"
        color="success"
        @click="handleSubmit('1', '7')"
      >
        任务完成
      </a-button>
      <a-button
        type="primary"
        v-if="record.showQxwcBtn"
        color="error"
        @click="handleSubmit('1', '6')"
      >
        取消完成
      </a-button>
      <a-button
        type="primary"
        v-if="record.showTjrw2Btn"
        color="success"
        @click="handleSubmit('1', '8')"
      >
        提交任务
      </a-button>

      <a-button
        type="primary"
        v-if="record.showShwcBtn"
        color="success"
        @click="handleSubmit('1', '9')"
      >
        审核完成
      </a-button>
      <a-button
        type="primary"
        v-if="record.showBxBtn"
        color="success"
        @click="handleSubmit('1', '10')"
      >
        报销完成
      </a-button>
      <a-button
        type="primary"
        v-if="record.showQxshBtn"
        color="error"
        @click="handleSubmit('1', '8')"
      >
        取消审核
      </a-button>
    </template>
    <BasicForm @register="registerForm">
      <template #carddYcddrwBtList>
        <BasicTable
          @register="registerCarddYcddrwBtTable"
          @row-click="handleCarddYcddrwBtRowClick"
          @edit-change="btEditChange"
        >
          <template #cdbhColumn="{ record }">
            asdasdas
            <!--            <Input v-model:value="record.ycddrwJcdbh" style="width: 20%" />-->
            <!--            <Input v-model:value="record.ycddrwCdbh" style="width: 30%" />-->
          </template>
          <template #childUpload1="{ record: childRecord }">
            <BasicUpload
              v-model:value="childRecord.dataMap"
              :bizKey="childRecord.id"
              :bizType="'carddYcddrw_file_bt_qs'"
              :uploadType="'all'"
              :loadTime="record.__t"
              :size="'small'"
              :isPreview="false"
            />
          </template>
          <template #childUpload2="{ record: childRecord }">
            <BasicUpload
              v-model:value="childRecord.dataMap"
              :bizKey="childRecord.id"
              :bizType="'carddYcddrw_file_bt_js'"
              :uploadType="'all'"
              :loadTime="record.__t"
              :size="'small'"
              :isPreview="false"
            />
          </template>
        </BasicTable>

        <a-button
          v-if="false"
          class="mt-2"
          @click="handleCarddYcddrwBtAdd"
          v-auth="'cardd:ddrw:carddYcddrw:edit'"
        >
          <Icon icon="i-ant-design:plus-circle-outlined" />
          {{ t('新增') }}
        </a-button>
      </template>
      <template #carddRyrwjjList>
        <BasicTable
          @register="registerCarddRyrwjjTable"
          @row-click="handleCarddRyrwjjRowClick"
          @edit-change="jjEditChange"
        >
          <template #summary>
            <TableSummary fixed>
              <TableSummaryRow>
                <TableSummaryCell v-for="(item, index) in totals" :index="index" align="right"
                  >{{ item }}
                </TableSummaryCell>
              </TableSummaryRow>
            </TableSummary>
          </template>
        </BasicTable>
        <a-button class="mt-2" @click="handleCarddRyrwjjAdd" v-auth="'cardd:ddrw:carddYcddrw:edit'">
          <Icon icon="i-ant-design:plus-circle-outlined" />
          {{ t('新增') }}
        </a-button>
      </template>
      <template #cdhSlot="{ model, field }">
        <a-input-group>
          <Row :gutter="5">
            <Col :span="12">
              <Input
                v-model:value="model[field]"
                :disabled="!(record.ycddrwRwzt == '6' || record.ycddrwRwzt == '8')"
              />
            </Col>
            <Col :span="12" v-if="record.ycddrwJcdbh">
              <Input v-model:value="record.ycddrwJcdbh" :disabled="true" prefix="原：" />
            </Col>
          </Row>
        </a-input-group>
      </template>
    </BasicForm>
    <BasicModal v-bind="$attrs" @register="register" title="退回原因" @ok="handleBack">
      <a-textarea v-model:value="thyy" placeholder="请输入退回原因" :auto-size="{ minRows: 10 }" />
    </BasicModal>
    <BasicModal
      v-bind="$attrs"
      @register="registerBackMsg"
      title="任务退回提醒"
      @ok="closeBackMsgModal"
    >
      任务被退回,原因为：{{ record.ycddrwThyy }}
    </BasicModal>
  </BasicDrawer>
</template>
<script lang="ts" setup name="ViewsCarddDdrwCarddYcddrwForm">
  import { computed, h, ref, unref } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicForm, useForm } from '/@/components/Form';
  import { BasicTable, useTable } from '/@/components/Table';
  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import {
    CarddYcddrw,
    carddYcddrwBack,
    carddYcddrwForm,
    carddYcddrwGenerate,
    carddYcddrwSave,
  } from '/@/api/cardd/ddrw/carddYcddrw';
  import { BasicUpload } from '/@/components/Upload';
  import { BasicModal, useModal } from '/@/components/Modal';

  import {
    Col,
    Divider,
    Input,
    Row,
    TableSummary,
    TableSummaryCell,
    TableSummaryRow,
  } from 'ant-design-vue';
  import dayjs from 'dayjs';
  import { usePermission } from '/@/hooks/web/usePermission';

  const emit = defineEmits(['success', 'register']);

  const { t } = useI18n('cardd.ddrw.carddYcddrw');
  const { showMessage } = useMessage();
  const { hasPermission } = usePermission();
  const { meta } = unref(router.currentRoute);
  const record = ref<CarddYcddrw>({} as CarddYcddrw);

  const thyy = ref<string>('');

  const getTitle = computed(() => ({
    icon: meta.icon || 'i-ant-design:book-outlined',
    value: record.value.isNewRecord ? t('新增用车订单任务') : t('编辑用车订单任务'),
  }));

  const [register, { openModal, closeModal }] = useModal();
  const [registerBackMsg, { openModal: openBackMsgModal, closeModal: closeBackMsgModal }] =
    useModal();

  const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm();
  // {
  //   labelWidth: 120,
  //   schemas: inputFormSchemas,
  //   baseColProps: { lg: 6, md: 24 },
  // }

  const totals = computed(() => {
    let sumryrwjjZhj: number = 0;
    let sumryrwjjXdhj: number = 0;
    let sumryrwjjBthj: number = 0;
    let sumryrwjjQthj: number = 0;
    let sumryrwjjCshj: number = 0;
    let sumryrwjjCglh: number = 0;
    let sumryrwjjDdhj: number = 0;
    let sumryrwjjTcf: number = 0;
    let sumryrwjjXcf: number = 0;
    let sumryrwjjCf: number = 0;
    let sumryrwjjCdf: number = 0;
    let sumryrwjjQtfy: number = 0;

    for (const record of carddRyrwjjTable.getDataSource()) {
      console.log('record', record);
      // 计算总金额
      const {
        editValueRefs: {
          ryrwjjZhj,
          ryrwjjXdhj,
          ryrwjjBthj,
          ryrwjjQthj,
          ryrwjjCshj,
          ryrwjjCglhj,
          ryrwjjDdhj,
          ryrwjjTcf,
          ryrwjjXcf,
          ryrwjjCf,
          ryrwjjCdf,
          ryrwjjQtfy,
        },
      } = record;
      sumryrwjjZhj += Number(ryrwjjZhj);
      sumryrwjjXdhj += Number(ryrwjjXdhj);
      sumryrwjjBthj += Number(ryrwjjBthj);
      sumryrwjjQthj += Number(ryrwjjQthj);
      sumryrwjjCshj += Number(ryrwjjCshj);
      sumryrwjjCglh += Number(ryrwjjCglhj);
      sumryrwjjDdhj += Number(ryrwjjDdhj);
      sumryrwjjTcf += Number(ryrwjjTcf);
      sumryrwjjXcf += Number(ryrwjjXcf);
      sumryrwjjCf += Number(ryrwjjCf);
      sumryrwjjCdf += Number(ryrwjjCdf);
      sumryrwjjQtfy += Number(ryrwjjQtfy);
    }
    // return {
    //   ryrwjjXd: '合计',
    //   ryrwjjZhj: sumryrwjjZhj.toFixed(2),
    //   ryrwjjXdhj: sumryrwjjXdhj.toFixed(2),
    //   ryrwjjBthj: sumryrwjjBthj.toFixed(2),
    //   ryrwjjQthj: sumryrwjjQthj.toFixed(2),
    //   ryrwjjCshj: sumryrwjjCshj.toFixed(2),
    //   ryrwjjCglhj: sumryrwjjCglh.toFixed(2),
    //   ryrwjjDdhj: sumryrwjjDdhj.toFixed(2),
    // };
    return [
      '',
      '合计',
      '',
      sumryrwjjXdhj.toFixed(2),
      '',
      '',
      sumryrwjjBthj.toFixed(2),
      '',
      '',
      sumryrwjjQthj.toFixed(2),
      '',
      '',
      sumryrwjjCshj.toFixed(2),
      '',
      '',
      sumryrwjjCglh.toFixed(2),
      '',
      '',
      sumryrwjjDdhj.toFixed(2),
      sumryrwjjTcf.toFixed(2),
      sumryrwjjXcf.toFixed(2),
      sumryrwjjCf.toFixed(2),
      sumryrwjjCdf.toFixed(2),
      sumryrwjjQtfy.toFixed(2),
      sumryrwjjZhj.toFixed(2),
    ];
  });

  const [registerCarddRyrwjjTable, carddRyrwjjTable] = useTable({
    actionColumn: {
      width: 60,
      actions: (record: Recordable) => [
        {
          icon: 'i-ant-design:delete-outlined',
          color: 'error',
          popConfirm: {
            title: '是否确认删除',
            confirm: handleCarddRyrwjjDelete.bind(this, record),
          },
          auth: 'cardd:ddrw:carddYcddrw:edit',
        },
      ],
    },
    rowKey: 'id',
    pagination: false,
    bordered: true,
    size: 'small',
    inset: true,
    scroll: { x: 1200 },
    // summaryFunc: () => {
    //   // let sumryrwjjZhj: number = 0;
    //   // let sumryrwjjXdhj: number = 0;
    //   // let sumryrwjjBthj: number = 0;
    //   // let sumryrwjjQthj: number = 0;
    //   // let sumryrwjjCshj: number = 0;
    //   // let sumryrwjjCglh: number = 0;
    //   // let sumryrwjjDdhj: number = 0;
    //   //
    //   // for (const record of carddRyrwjjTable.getDataSource()) {
    //   //   console.log('record', record);
    //   //   // 计算总金额
    //   //   const {
    //   //     editValueRefs: {
    //   //       ryrwjjZhj,
    //   //       ryrwjjXdhj,
    //   //       ryrwjjBthj,
    //   //       ryrwjjQthj,
    //   //       ryrwjjCshj,
    //   //       ryrwjjCglhj,
    //   //       ryrwjjDdhj,
    //   //     },
    //   //   } = record;
    //   //   sumryrwjjZhj += Number(ryrwjjZhj);
    //   //   sumryrwjjXdhj += Number(ryrwjjXdhj);
    //   //   sumryrwjjBthj += Number(ryrwjjBthj);
    //   //   sumryrwjjQthj += Number(ryrwjjQthj);
    //   //   sumryrwjjCshj += Number(ryrwjjCshj);
    //   //   sumryrwjjCglh += Number(ryrwjjCglhj);
    //   //   sumryrwjjDdhj += Number(ryrwjjDdhj);
    //   // }
    //   // return [
    //   //   {
    //   //     ryrwjjXd: '合计',
    //   //     ryrwjjZhj: sumryrwjjZhj.toFixed(2),
    //   //     ryrwjjXdhj: sumryrwjjXdhj.toFixed(2),
    //   //     ryrwjjBthj: sumryrwjjBthj.toFixed(2),
    //   //     ryrwjjQthj: sumryrwjjQthj.toFixed(2),
    //   //     ryrwjjCshj: sumryrwjjCshj.toFixed(2),
    //   //     ryrwjjCglhj: sumryrwjjCglh.toFixed(2),
    //   //     ryrwjjDdhj: sumryrwjjDdhj.toFixed(2),
    //   //   },
    //   // ];
    //   console.log(11111);
    //   return [{ ryrwjjXd: '合计' }];
    // },
    // showSummary: true,
    // summaryData: [
    //   {
    //     key: 'ryrwjjXdhj',
    //     index: 0,
    //     render: (text: string, record: Recordable) => {
    //       return record.ryrwjjXd * record.ryrwjjXdsl;
    //     },
    //   },
    // ],
  });

  const [registerCarddYcddrwBtTable, carddYcddrwBtTable] = useTable({
    // actionColumn: {
    //   width: 60,
    //   actions: (record: Recordable) => [
    //     {
    //       icon: 'i-ant-design:delete-outlined',
    //       color: 'error',
    //       popConfirm: {
    //         title: '是否确认删除',
    //         confirm: handleCarddYcddrwBtDelete.bind(this, record),
    //       },
    //       auth: 'cardd:ddrw:carddYcddrw:edit',
    //     },
    //   ],
    // },
    rowKey: 'id',
    pagination: false,
    bordered: true,
    size: 'small',
    inset: true,
  });

  async function setCarddYcddrwBtTableData(_res: Recordable) {
    carddYcddrwBtTable.setColumns([
      {
        title: t('日期'),
        dataIndex: 'btRq',
        width: 215,
        align: 'center',
        editRow: true,
        editComponent: 'DatePicker',
        editComponentProps: {
          format: 'YYYY-MM-DD',
          // showTime: { format: 'HH:mm' },
        },
        editRule: false,
        ifShow: false,
      },
      {
        title: t('行驶路线'),
        dataIndex: 'btXslx',
        width: 130,
        align: 'left',
        editRow: true,
        editComponent: 'Input',
        editComponentProps: {
          maxlength: 100,
        },
        editRule: false,
      },
      {
        title: t('起始路码'),
        dataIndex: 'btQslm',
        width: 130,
        align: 'center',
        editRow: true,
        editComponent: 'Input',
        editComponentProps: {
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('起始路码照片'),
        dataIndex: 'upload',
        width: 160,
        align: 'center',
        slot: 'childUpload1',
      },
      {
        title: t('结束路码'),
        dataIndex: 'btJslm',
        width: 130,
        align: 'center',
        editRow: true,
        editComponent: 'Input',
        editComponentProps: {
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('结束路码照片'),
        dataIndex: 'upload',
        width: 160,
        align: 'center',
        slot: 'childUpload2',
      },
      {
        title: t('实际公里'),
        dataIndex: 'btSjgl',
        width: 130,
        align: 'center',
        editRow: true,
        editComponent: 'Input',
        editComponentProps: {
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('上车时间'),
        dataIndex: 'btScsj',
        width: 215,
        align: 'center',
        editRow: true,
        editComponent: 'DatePicker',
        editComponentProps: {
          format: 'YYYY-MM-DD HH:mm',
          showTime: { format: 'HH:mm' },
        },
        editRule: false,
      },
      {
        title: t('下车时间'),
        dataIndex: 'btXcsj',
        width: 215,
        align: 'center',
        editRow: true,
        editComponent: 'DatePicker',
        editComponentProps: {
          format: 'YYYY-MM-DD HH:mm',
          showTime: { format: 'HH:mm' },
        },
        editRule: false,
      },
      {
        title: t('超时时间'),
        dataIndex: 'btCssjxs',
        width: 130,
        align: 'center',
        editRow: true,
        editComponent: 'Input',
        editComponentProps: {
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('备注'),
        dataIndex: 'btBz',
        width: 130,
        align: 'center',
        editRow: true,
        editComponent: 'Input',
        editComponentProps: {
          maxlength: 2000,
        },
        editRule: false,
      },
      // {
      //   title: t('退回原因'),
      //   dataIndex: 'ycddrwThyy',
      //   width: 130,
      //   align: 'center',
      //   editRow: true,
      //   editComponent: 'Input',
      //   editComponentProps: {
      //     maxlength: 2000,
      //   },
      //   editRule: false,
      // },
    ]);
    carddYcddrwBtTable.setTableData(record.value.carddYcddrwBtList || []);
  }

  async function setCarddRyrwjjTableData(_res: Recordable) {
    carddRyrwjjTable.setColumns([
      {
        title: t('工资结构'),
        children: [
          {
            title: t('小单'),
            dataIndex: 'ryrwjjXd',
            width: 60,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: () => {
              return {
                controls: false,
                maxlength: 8,
              };
            },
            editRule: false,
          },
          {
            title: t('数量'),
            dataIndex: 'ryrwjjXdsl',
            width: 50,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('小计'),
            dataIndex: 'ryrwjjXdhj',
            width: 70,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('半天'),
            dataIndex: 'ryrwjjBt',
            width: 60,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('数量'),
            dataIndex: 'ryrwjjBtsl',
            width: 50,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('小计'),
            dataIndex: 'ryrwjjBthj',
            width: 70,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('全天'),
            dataIndex: 'ryrwjjQt',
            width: 60,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('天数'),
            dataIndex: 'ryrwjjQtsl',
            width: 50,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('小计'),
            dataIndex: 'ryrwjjQthj',
            width: 70,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
        ],
      },
      {
        title: t('超时'),
        children: [
          {
            title: t('超时'),
            dataIndex: 'ryrwjjCs',
            width: 50,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('单价'),
            dataIndex: 'ryrwjjCsdj',
            width: 60,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('小计'),
            dataIndex: 'ryrwjjCshj',
            width: 70,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
        ],
      },
      {
        title: t('超公里'),
        children: [
          {
            title: t('超公里'),
            dataIndex: 'ryrwjjCgl',
            width: 50,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('单价'),
            dataIndex: 'ryrwjjCgldj',
            width: 60,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('小计'),
            dataIndex: 'ryrwjjCglhj',
            width: 70,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
        ],
      },
      {
        title: t('点单'),
        children: [
          {
            title: t('点单'),
            dataIndex: 'ryrwjjDd',
            width: 60,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('数量'),
            dataIndex: 'ryrwjjDdsl',
            width: 50,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
          {
            title: t('小计'),
            dataIndex: 'ryrwjjDdhj',
            width: 70,
            align: 'right',
            editRow: true,
            editComponent: 'InputNumber',
            editComponentProps: {
              controls: false,
              maxlength: 8,
            },
            editRule: false,
          },
        ],
      },
      {
        title: t('停车费'),
        dataIndex: 'ryrwjjTcf',
        width: 60,
        align: 'right',
        editRow: true,
        editComponent: 'InputNumber',
        editComponentProps: {
          controls: false,
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('洗车费'),
        dataIndex: 'ryrwjjXcf',
        width: 60,
        align: 'right',
        editRow: true,
        editComponent: 'InputNumber',
        editComponentProps: {
          controls: false,
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('餐费'),
        dataIndex: 'ryrwjjCf',
        width: 60,
        align: 'right',
        editRow: true,
        editComponent: 'InputNumber',
        editComponentProps: {
          controls: false,
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('充电费'),
        dataIndex: 'ryrwjjCdf',
        width: 60,
        align: 'right',
        editRow: true,
        editComponent: 'InputNumber',
        editComponentProps: {
          controls: false,
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('其他费用'),
        dataIndex: 'ryrwjjQtfy',
        width: 60,
        align: 'right',
        editRow: true,
        editComponent: 'InputNumber',
        editComponentProps: {
          controls: false,
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('合计'),
        dataIndex: 'ryrwjjZhj',
        width: 80,
        align: 'right',
        editRow: true,
        editComponent: 'InputNumber',
        editComponentProps: {
          controls: false,
          maxlength: 8,
        },
        editRule: false,
      },
      {
        title: t('备注'),
        dataIndex: 'ryrwjjBz',
        width: 100,
        align: 'left',
        editRow: true,
        editComponent: 'Input',
        editComponentProps: {
          maxlength: 2000,
        },
        editRule: false,
      },
    ]);
    carddRyrwjjTable.setTableData(record.value.carddRyrwjjList || []);
  }

  function handleCarddYcddrwBtAdd() {
    carddYcddrwBtTable.insertTableDataRecord({
      id: new Date().getTime(),
      isNewRecord: true,
      editable: true,
    });
  }

  function handleCarddRyrwjjRowClick(record: Recordable) {
    record.onEdit?.(true, false);
  }

  function handleCarddRyrwjjAdd() {
    carddRyrwjjTable.insertTableDataRecord({
      id: new Date().getTime(),
      isNewRecord: true,
      editable: true,
    });
  }

  function handleCarddRyrwjjDelete(record: Recordable) {
    carddRyrwjjTable.deleteTableDataRecord(record);
  }

  function handleCarddYcddrwBtRowClick(record: Recordable) {
    record.onEdit?.(true, false);
  }

  // function handleCarddYcddrwBtDelete(record: Recordable) {
  //   carddYcddrwBtTable.deleteTableDataRecord(record);
  // }

  async function getCarddRyrwjjList() {
    let carddRyrwjjListValid = true;
    let carddRyrwjjList: Recordable[] = [];
    for (const record of carddRyrwjjTable.getDataSource()) {
      if (!(await record.onEdit?.(false, true))) {
        carddRyrwjjListValid = false;
      }
      carddRyrwjjList.push({
        ...record,
        id: !!record.isNewRecord ? '' : record.id,
      });
    }
    for (const record of carddRyrwjjTable.getDelDataSource()) {
      if (!!record.isNewRecord) continue;
      carddRyrwjjList.push({
        ...record,
        status: '1',
      });
    }
    if (!carddRyrwjjListValid) {
      throw { errorFields: [{ name: ['carddRyrwjjList'] }] };
    }
    return carddRyrwjjList;
  }

  async function getCarddYcddrwBtList() {
    let carddYcddrwBtListValid = true;
    let carddYcddrwBtList: Recordable[] = [];
    for (const record of carddYcddrwBtTable.getDataSource()) {
      if (!(await record.onEdit?.(false, true))) {
        carddYcddrwBtListValid = false;
      }
      carddYcddrwBtList.push({
        ...record,
        id: !!record.isNewRecord ? '' : record.id,
      });
    }
    for (const record of carddYcddrwBtTable.getDelDataSource()) {
      if (!!record.isNewRecord) continue;
      carddYcddrwBtList.push({
        ...record,
        status: '1',
      });
    }
    if (!carddYcddrwBtListValid) {
      throw { errorFields: [{ name: ['carddYcddrwBtList'] }] };
    }
    return carddYcddrwBtList;
  }

  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
    setDrawerProps({ loading: true });
    await resetFields();
    const res = await carddYcddrwForm(data);
    try {
      const start = dayjs(res.carddYcddrw?.carddYcddBt?.btKsrq);
      const end = dayjs(res.carddYcddrw?.carddYcddBt?.btJsrq);
      // 计算差异
      const duration = end.diff(start, 'second'); // 获取秒数差异
      // 转换为天数和小时数
      const days = Math.floor(duration / (24 * 60 * 60)); // 计算天数
      const hours = Math.floor((duration % (24 * 60 * 60)) / 3600); // 计算剩余的小时数
      // 小时数转为小数天数
      const day = Number(days) + hours / 24;

      // 设置到表单中
      res.carddYcddrw['ycddrwYcts'] = `${day.toFixed(1)}`; //天${hours}小时;
    } catch (e) {
      console.log(e);
    }
    record.value = (res.carddYcddrw || {}) as CarddYcddrw;
    record.value.__t = new Date().getTime();
    await setProps({
      labelWidth: 120,
      schemas: [
        {
          label: t('订单编号'),
          field: 'carddYcdd.ycddDdbh',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('用车单位'),
          field: 'carddYcdd.basCus.khdaDwqc',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('联系人'),
          // field: 'carddYcdd.ycddLxr',
          field: 'carddYcdd.contact.khlxrLxrmc',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('联系电话'),
          field: 'carddYcdd.ycddLxdh',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('租赁方式'),
          field: 'carddYcddBt.btZlfs',
          component: 'Select',
          componentProps: {
            dictType: 'car_zlfs',
            allowClear: true,
          },
          dynamicDisabled: true,
        },
        {
          label: t('车牌号'),
          field: 'carddYcddBt.btCph',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('车辆类型'),
          field: 'carddYcddBt.btPpxh',
          component: 'Select',
          componentProps: {
            dictType: 'car_type',
            allowClear: true,
          },
          dynamicDisabled: true,
        },
        {
          label: t('驾驶员'),
          field: 'carddYcddBt.btJsy',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },

        {
          label: t('外调类型'),
          field: 'carddYcddBt.btWdlx',
          component: 'Select',
          componentProps: {
            dictType: 'car_wdlx',
            allowClear: true,
          },
          dynamicDisabled: true,
        },
        {
          label: t('外调单位'),
          field: 'carddYcddBt.btWddw',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('外调对接人'),
          field: 'carddYcddBt.btClr',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },

        // {
        //   label: t('任务状态'),
        //   field: 'ycddrwRwzt',
        //   component: 'Select',
        //   componentProps: {
        //     dictType: 'car_ddzxzt',
        //     allowClear: true,
        //   },
        //   dynamicDisabled: true,
        // },
        {
          label: t('业务员'),
          field: 'carddYcdd.ycddYwy',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
          ifShow: false,
        },

        {
          label: t('任务单号'),
          field: 'ycddrwRwdh',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('开始日期'),
          field: 'carddYcddBt.btKsrq',
          component: 'DatePicker',
          componentProps: {
            format: 'YYYY-MM-DD HH:mm',
            showTime: { format: 'HH:mm' },
          },
          dynamicDisabled: true,
        },
        {
          label: t('结束日期'),
          field: 'carddYcddBt.btJsrq',
          component: 'DatePicker',
          componentProps: {
            format: 'YYYY-MM-DD HH:mm',
            showTime: { format: 'HH:mm' },
          },
          dynamicDisabled: true,
        },
        {
          label: t('用车天数'),
          field: 'ycddrwYcts',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          dynamicDisabled: true,
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个正整数'),
            },
          ],
        },
        {
          label: t('部门'),
          field: 'carddYcdd.ycddBm',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('上车地点'),
          field: 'carddYcddBt.btScdd',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('上车时间'),
          field: 'carddYcddBt.btScsj',
          component: 'DatePicker',
          componentProps: {
            format: 'YYYY-MM-DD HH:mm',
            showTime: { format: 'HH:mm' },
          },
          dynamicDisabled: true,
        },
        {
          label: t('车单编号'),
          field: 'ycddrwCdbh',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          slot: 'cdhSlot',
          dynamicDisabled: () =>
            !(record.value.ycddrwRwzt == '6' || record.value.ycddrwRwzt == '8'),
          required: () => record.value.ycddrwRwzt == '6' || record.value.ycddrwRwzt == '8',
        },
        {
          label: t('车单照片'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_cdzp',
            uploadType: 'image',
            disabled:
              record.value.ycddrwRwzt != '6' && record.value.ycddrwRwzt != '8' ? true : false,
          },
          // dynamicDisabled:record.value.ycddrwRwzt != '6' && record.value.ycddrwRwzt != '8' ? true:false,
          rules: [
            {
              required: computed(
                () => record.value.ycddrwRwzt == '6' || record.value.ycddrwRwzt == '8',
              ),
              validator(_rule, value) {
                return new Promise((resolve, reject) => {
                  if (!(record.value.ycddrwRwzt == '6' || record.value.ycddrwRwzt == '8')) {
                    resolve();
                    return;
                  }
                  const len = !value || value['carddYcddrw_file_cdzp__len'] || 0;
                  if (len == 0) reject(t('请上传图片'));
                  else resolve();
                });
              },
            },
          ],
        },
        {
          label: t('座位数'),
          field: 'carddYcddBt.btZws',
          component: 'Input',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
        },
        {
          label: t('车辆行程'),
          field: 'carddYcddBt.btClxc',
          component: 'InputTextArea',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
          colProps: { lg: 24, md: 24 },
        },
        {
          label: t('车辆要求'),
          field: 'carddYcdd.ycddClyq',
          component: 'InputTextArea',
          componentProps: {
            maxlength: 100,
          },
          dynamicDisabled: true,
          colProps: { lg: 24, md: 24 },
        },
        // {
        //   label: t('备注'),
        //   field: 'ycddrwCdbh',
        //   component: 'InputTextArea',
        //   componentProps: {
        //     maxlength: 100,
        //   },
        //   dynamicDisabled: true,
        //   colProps: { lg: 24, md: 24 },
        // },

        {
          label: t('出发前照片'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_image_cf',
            uploadType: 'image',
            change: (fileList) => {
              console.log(fileList);
            },
          },
          colProps: { lg: 12, md: 24 },
          // 文件上传的必填验证实例
          // rules: [
          //   { required: record.value.ycddrwRwzt != '1' },
          //   {
          //     validator(_rule, value) {
          //       return new Promise((resolve, reject) => {
          //         const len = !value || value['carddYcddrw_image_cf__len'] || 0;
          //         if (len == 0) reject(t('请上传图片'));
          //         else resolve();
          //       });
          //     },
          //   },
          // ],
        },

        {
          label: t('拍照时间'),
          field: 'ycddrwPzsj',
          component: 'DatePicker',
          componentProps: {
            format: 'YYYY-MM-DD HH:mm',
            showTime: { format: 'HH:mm' },
          },
          dynamicDisabled: true,
          colProps: { lg: 12, md: 24 },
          // required: record.value.ycddrwRwzt != '1',
        },
        {
          label: t('车辆前方'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_image_qian',
            uploadType: 'image',
          },
          colProps: { lg: 12, md: 24 },
        },
        {
          label: t('车辆右侧'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_image_you',
            uploadType: 'image',
          },
          colProps: { lg: 12, md: 24 },
        },
        {
          label: t('车辆左侧'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_image_zuo',
            uploadType: 'image',
          },
          colProps: { lg: 12, md: 24 },
        },
        {
          label: t('车辆后方'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_image_hou',
            uploadType: 'image',
          },
          colProps: { lg: 12, md: 24 },
        },

        {
          label: t('车辆到达照片'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_image_dd',
            uploadType: 'image',
          },
          colProps: { lg: 12, md: 24 },
        },
        {
          label: t('到达时间'),
          field: 'ycddrwDdsj',
          component: 'DatePicker',
          componentProps: {
            format: 'YYYY-MM-DD HH:mm',
            showTime: { format: 'HH:mm' },
          },
          dynamicDisabled: true,
          colProps: { lg: 12, md: 24 },
        },

        {
          label: t(''),
          field: 'carddYcddrwBtList',
          component: 'Input',
          colProps: { lg: 24, md: 24 },
          slot: 'carddYcddrwBtList',
        },
        {
          label: t('用油公里数'),
          field: 'ycddrwYygls',
          component: 'Input',
          // componentProps: {
          //   maxlength: 8,
          // },
          // 取值和实际公里数一致
          componentProps: ({ formModel }) => {
            console.log('formModel', formModel);
          },
          colProps: { lg: 12, md: 24 },
          show: computed(() => shouldShowKilometerFields()),
          // record.value.basCar.xnyqc 为1 dynamicDisabled 为true
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
            // 显示的时候必填
            { required: record.value.basCar?.xnyqc == 1 && record.value.ycddrwRwzt == '6' },
          ],
        },
        {
          label: t('用电公里数'),
          field: 'ycddrwYdgls',
          component: 'Input',
          // componentProps: {
          //   maxlength: 8,
          //   // 占3
          // },
          // 用电公里数和
          colProps: { lg: 12, md: 24 },
          ifShow: computed(() => shouldShowKilometerFields()),
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
            // 显示的时候必填
            { required: record.value.basCar?.xnyqc == 1 && record.value.ycddrwRwzt == '6' },
          ],
        },
        {
          label: t('收费公里数'),
          field: 'ycddrwSfgls',
          component: 'Input',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 8,
              onInput: async () => {
                // 收费公里数×油费单价
                const yffj = formModel.ycddrwMxyfdj;
                const sfgls = formModel.ycddrwSfgls;
                if (yffj && sfgls) {
                  formModel.ycddrwMxcglyf = (Number(yffj) * Number(sfgls)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwMxcglyf = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('实际公里数'),
          field: 'ycddrwSjgls',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('绩效公里数'),
          field: 'ycddrwJxgls',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('打印日期'),
          field: 'ycddrwDyrq',
          component: 'DatePicker',
          componentProps: {
            format: 'YYYY-MM-DD',
            // showTime: { format: 'HH:mm' },
          },
        },
        {
          label: t('过路费'),
          field: 'ycddrwGlf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },

        {
          label: t('过路凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_glf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('现金加油费'),
          field: 'ycddrwJyf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('现金加油凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_wgyf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('油卡加油费'),
          field: 'ycddrwYkjyf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('油卡加油凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_ykjyf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('充电费'),
          field: 'ycddrwCdf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('充电凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_cdf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('交通费'),
          field: 'ycddrwJtf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('交通凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_jtf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('误餐费'),
          field: 'ycddrwWcf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('误餐凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_wcf',
            uploadType: 'all',
            isPreview: false,
          },
        },

        {
          label: t('矿泉水费'),
          field: 'ycddrwKqsf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('矿泉水凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_kqs',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('洗车费'),
          field: 'ycddrwXcf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('洗车凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_xcf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('车检费'),
          field: 'ycddrwCjf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('车检凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_cjf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('停车费'),
          field: 'ycddrwTcf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('停车凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_tcf',
            uploadType: 'all',
            isPreview: false,
          },
        },

        {
          label: t('其他费用'),
          field: 'ycddrwQtfy',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('其他凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_qt',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('住宿费'),
          field: 'ycddrwZsf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('住宿凭据'),
          field: 'dataMap',
          component: 'Upload',
          componentProps: {
            loadTime: computed(() => record.value.__t),
            bizKey: computed(() => record.value.id),
            bizType: 'carddYcddrw_file_zsf',
            uploadType: 'all',
            isPreview: false,
          },
        },
        {
          label: t('其他费用描述'),
          field: 'ycddrwQtfyms',
          component: 'Input',
          componentProps: {
            maxlength: 2000,
          },
        },
        {
          label: t('现金报销'),
          field: 'ycddrwXjbx',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('入工资'),
          field: 'ycddrwRgz',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
        },
        {
          label: t('用车人'),
          field: 'ycddrwLxr',
          component: 'Input',
          componentProps: {
            maxlength: 2000,
          },
        },
        // {
        //   label: t('超公里'),
        //   field: 'cgl',
        //   component: 'Input',
        //   slot: 'cglSlot',
        //   colProps: { lg: 24, md: 24 },
        // },
        {
          field: 'zcfymx',
          component: 'Text',
          colProps: { lg: 24, md: 24 },
          render: () => {
            return h(Divider, {}, '租车费用明细');
          },
        },
        {
          label: t('半日租金单价'),
          field: 'ycddrwBrzjdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过半日租金和半日租金数量计算半日租金金额
                const brzj = formModel.ycddrwBrzjdj;
                const brzjsl = formModel.ycddrwBrzjsl;
                if (brzj && brzjsl) {
                  formModel.ycddrwBrzjje = (Number(brzj) * Number(brzjsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwBrzjje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('半日租金数量'),
          field: 'ycddrwBrzjsl',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过半日租金和半日租金数量计算半日租金金额
                const brzj = formModel.ycddrwBrzjdj;
                const brzjsl = formModel.ycddrwBrzjsl;
                if (brzj && brzjsl) {
                  formModel.ycddrwBrzjje = (Number(brzj) * Number(brzjsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwBrzjje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('半日租金金额'),
          field: 'ycddrwBrzjje',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('日租金单价'),
          field: 'ycddrwRzjdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过日租金和日租金数量计算日租金金额
                const rzj = formModel.ycddrwRzjdj;
                const rzjsl = formModel.ycddrwRzjsl;
                if (rzj && rzjsl) {
                  formModel.ycddrwRzjje = (Number(rzj) * Number(rzjsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwRzjje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('日租金数量'),
          field: 'ycddrwRzjsl',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过日租金和日租金数量计算日租金金额
                const rzj = formModel.ycddrwRzjdj;
                const rzjsl = formModel.ycddrwRzjsl;
                if (rzj && rzjsl) {
                  formModel.ycddrwRzjje = (Number(rzj) * Number(rzjsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwRzjje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('日租金金额'),
          field: 'ycddrwRzjje',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('接送机/火车'),
          field: 'ycddrwJsdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过接送单价和接送数量计算接送金额
                const jsdj = formModel.ycddrwJsdj;
                const jssl = formModel.ycddrwJssl;
                if (jsdj && jssl) {
                  formModel.ycddrwJsje = (Number(jsdj) * Number(jssl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwJsje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('接送机/火车'),
          field: 'ycddrwJssl',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过接送单价和接送数量计算接送金额
                const jsdj = formModel.ycddrwJsdj;
                const jssl = formModel.ycddrwJssl;
                if (jsdj && jssl) {
                  formModel.ycddrwJsje = (Number(jsdj) * Number(jssl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwJsje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('接送机/火车'),
          field: 'ycddrwJsje',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('半日工资单价'),
          field: 'ycddrwBrgzdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过半日工资和半日工资数量计算半日工资金额
                const brgz = formModel.ycddrwBrgzdj;
                const brgzsl = formModel.ycddrwBrgzsl;
                if (brgz && brgzsl) {
                  formModel.ycddrwBrgzje = (Number(brgz) * Number(brgzsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwBrgzje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: {
            lg: 8,
            md: 24,
          },
        },
        {
          label: t('半日工资数量'),
          field: 'ycddrwBrgzsl',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过半日工资和半日工资数量计算半日工资金额
                const brgz = formModel.ycddrwBrgzdj;
                const brgzsl = formModel.ycddrwBrgzsl;
                if (brgz && brgzsl) {
                  formModel.ycddrwBrgzje = (Number(brgz) * Number(brgzsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwBrgzje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: {
            lg: 8,
            md: 24,
          },
        },
        {
          label: t('半日工资金额'),
          field: 'ycddrwBrgzje',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('日工资单价'),
          field: 'ycddrwRgzdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过日工资和日工资数量计算日工资金额
                const rgz = formModel.ycddrwRgzdj;
                const rgzsl = formModel.ycddrwRgzsl;
                if (rgz && rgzsl) {
                  formModel.ycddrwRgzje = (Number(rgz) * Number(rgzsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwRgzje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              // 8位整数，2位小数
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d{1,2})?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('日工资数量'),
          field: 'ycddrwRgzsl',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过日工资和日工资数量计算日工资金额
                const rgz = formModel.ycddrwRgzdj;
                const rgzsl = formModel.ycddrwRgzsl;
                if (rgz && rgzsl) {
                  formModel.ycddrwRgzje = (Number(rgz) * Number(rgzsl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwRgzje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('日工资金额'),
          field: 'ycddrwRgzje',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超时单价'),
          field: 'ycddrwCsdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过超时单价和超时时间计算超时金额
                const csdj = formModel.ycddrwCsdj;
                const cssj = formModel.ycddrwCssj;
                if (csdj && cssj) {
                  formModel.ycddrwCsje = (Number(csdj) * Number(cssj)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwCsje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超时时间'),
          field: 'ycddrwCssj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // 通过超时单价和超时时间计算超时金额
                const csdj = formModel.ycddrwCsdj;
                const cssj = formModel.ycddrwCssj;
                if (csdj && cssj) {
                  formModel.ycddrwCsje = (Number(csdj) * Number(cssj)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwCsje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超时金额'),
          field: 'ycddrwCsje',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超公里单价'),
          field: 'ycddrwCgldj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                console.log(1111);
                // 通过超公里单价和超公里数计算超公里金额
                const cgldj = formModel.ycddrwCgldj;
                const cgl = formModel.ycddrwClcs;
                if (cgldj && cgl) {
                  formModel.ycddrwClcje = (Number(cgldj) * Number(cgl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwClcje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: {
            lg: 8,
            md: 24,
          },
        },
        {
          label: t('超里程数'),
          field: 'ycddrwClcs',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 8,
              onInput: async () => {
                // 通过超公里单价和超公里数计算超公里金额
                const cgldj = formModel.ycddrwCgldj;
                const cgl = formModel.ycddrwClcs;
                if (cgldj && cgl) {
                  formModel.ycddrwClcje = (Number(cgldj) * Number(cgl)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwClcje = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超里程金额'),
          field: 'ycddrwClcje',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('油费'),
          field: 'ycddrwMxyf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
          ifShow: false,
        },
        {
          label: t('油卡油费'),
          field: 'ycddrwMxykjyf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
          ifShow: false,
        },
        {
          label: t('油费单价'),
          field: 'ycddrwMxyfdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 8,
              onInput: async () => {
                // 收费公里数×油费单价
                const yffj = formModel.ycddrwMxyfdj;
                const sfgls = formModel.ycddrwSfgls;
                if (yffj && sfgls) {
                  formModel.ycddrwMxcglyf = (Number(yffj) * Number(sfgls)).toFixed(2);
                  computHjje(formModel);
                } else {
                  formModel.ycddrwMxcglyf = '';
                  computHjje(formModel);
                }
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('油费'),
          field: 'ycddrwMxcglyf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('过路费'),
          field: 'ycddrwMxglf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('停车费'),
          field: 'ycddrwMxtcf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('洗车费'),
          field: 'ycddrwMxxcf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('住宿费'),
          field: 'ycddrwMxzsf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('餐费'),
          field: 'ycddrwMxcf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('其他'),
          field: 'ycddrwMxqtfy',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('基础价'),
          field: 'ycddrwJcj',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
          ifShow: false,
        },
        {
          label: t('基础公里'),
          field: 'ycddrwJcgl',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
          ifShow: false,
        },
        {
          label: t('基础时长'),
          field: 'ycddrwJcsz',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
          ifShow: false,
        },
        {
          label: t('车费'),
          field: 'ycddrwCf',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
          ifShow: false,
        },
        {
          label: t('支出合计'),
          field: 'ycddrwZchj',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
          ifShow: false,
        },
        {
          label: t('合计金额'),
          field: 'ycddrwHjje',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('报销金额'),
          field: 'ycddrwBxje',
          component: 'Input',
          componentProps: {
            maxlength: 8,
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value.ycddrwRwzt == '9';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('备注'),
          field: 'ycddrwBz',
          component: 'InputTextArea',
          componentProps: {
            maxlength: 2000,
          },
          colProps: { lg: 24, md: 24 },
        },
        {
          field: '',
          component: 'Text',
          colProps: { lg: 24, md: 24 },
          render: () => {
            return h(Divider, {}, '人员奖金明细');
          },
        },
        {
          label: t(''),
          field: 'carddRyrwjjList',
          component: 'Input',
          colProps: { lg: 24, md: 24 },
          slot: 'carddRyrwjjList',
        },
        {
          field: '',
          component: 'Text',
          colProps: { lg: 24, md: 24 },
          render: () => {
            return h(Divider, {}, '外调费用明细');
          },
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
        },
        {
          label: t('超公里'),
          field: 'ycddrwZccgls',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                const cgldj = formModel.ycddrwZccgldj;
                const cgl = formModel.ycddrwZccgls;
                if (cgldj && cgl) {
                  formModel.ycddrwZccglxj = (Number(cgldj) * Number(cgl)).toFixed(2);
                } else {
                  formModel.ycddrwZccglxj = '';
                }
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超公里单价'),
          field: 'ycddrwZccgldj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                const cgldj = formModel.ycddrwZccgldj;
                const cgl = formModel.ycddrwZccgls;
                if (cgldj && cgl) {
                  formModel.ycddrwZccglxj = (Number(cgldj) * Number(cgl)).toFixed(2);
                } else {
                  formModel.ycddrwZccglxj = '';
                }
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超公里小计'),
          field: 'ycddrwZccglxj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超时'),
          field: 'ycddrwZccss',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                const csdj = formModel.ycddrwZccsdj;
                const cs = formModel.ycddrwZccss;
                if (csdj && cs) {
                  formModel.ycddrwZccsxj = (Number(csdj) * Number(cs)).toFixed(2);
                } else {
                  formModel.ycddrwZccsxj = '';
                }
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超时单价'),
          field: 'ycddrwZccsdj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                const csdj = formModel.ycddrwZccsdj;
                const cs = formModel.ycddrwZccss;
                if (csdj && cs) {
                  formModel.ycddrwZccsxj = (Number(csdj) * Number(cs)).toFixed(2);
                } else {
                  formModel.ycddrwZccsxj = '';
                }
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('超时小计'),
          field: 'ycddrwZccsxj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('过路费'),
          field: 'ycddrwZcglf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('停车费'),
          field: 'ycddrwZctcf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('餐费'),
          field: 'ycddrwZccf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('租金'),
          field: 'ycddrwZczj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('合计'),
          field: 'ycddrwZcxj',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                computWdfyHj(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('人工费'),
          field: 'ycddrwZcrgf',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
        {
          label: t('税点'),
          field: 'ycddrwZcsl',
          component: 'InputNumber',
          componentProps: ({ formModel }) => {
            return {
              controls: false,
              maxlength: 10,
              onInput: async () => {
                // computHjje(formModel);
              },
            };
          },
          rules: [
            {
              pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
              message: t('请输入一个数值'),
            },
          ],
          show: () => {
            return record.value?.carddYcddBt?.btWdlx == '3';
          },
          colProps: { lg: 8, md: 24 },
        },
      ],
      baseColProps: { lg: 6, md: 24 },
    });

    setFieldsValue(record.value);
    setCarddRyrwjjTableData(res);
    setCarddYcddrwBtTableData(res);
    setDrawerProps({ loading: false });
    if (record.value.status == '5') {
      openBackMsgModal();
    }
  });

  function shouldShowKilometerFields(): boolean {
    const validStatuses = ['6', '7', '8', '9', '10'];
    console.log('record.value.ycddrwRwzt', record.value, validStatuses.includes(record.value.ycddrwRwzt) && record.value.basCar?.xnyqc === 1 , validStatuses.includes(record.value.ycddrwRwzt));
    return validStatuses.includes(record.value.ycddrwRwzt) && record.value.basCar?.xnyqc == 1;
  }

  async function handleSubmit(ope: string, newStatus: string) {
    try {
      const data = await validate();
      setDrawerProps({ confirmLoading: true });
      const params: any = {
        isNewRecord: record.value.isNewRecord,
        id: record.value.id,
        ycddrwDdxxmxid: record.value.ycddrwDdxxmxid,
        ycddrwDdxxzbid: record.value.ycddrwDdxxzbid,
      };
      data.carddRyrwjjList = await getCarddRyrwjjList();
      data.carddYcddrwBtList = await getCarddYcddrwBtList();
      data.ope = ope;
      data.oldStatus = record.value.ycddrwRwzt;
      data.newStatus = newStatus;
      const res = await carddYcddrwSave(params, data);
      showMessage(res.message);
      setTimeout(closeDrawer);
      emit('success', data);
    } catch (error: any) {
      if (error && error.errorFields) {
        showMessage(t('common.validateError'));
      }
      console.log('error', error);
    } finally {
      setDrawerProps({ confirmLoading: false });
    }
  }

  const openBackForm = () => {
    thyy.value = '';
    openModal();
  };

  /**
   * 任务退回
   */
  async function handleBack() {
    try {
      closeModal();
      setDrawerProps({ confirmLoading: true });
      const params: any = {
        isNewRecord: record.value.isNewRecord,
        id: record.value.id,
        oldStatus: record.value.ycddrwRwzt,
        ycddrwThyy: thyy.value,
      };
      const res = await carddYcddrwBack(params);
      showMessage(res.message);
      setTimeout(closeDrawer);
      emit('success');
    } catch (error: any) {
      if (error && error.errorFields) {
        showMessage(t('common.validateError'));
      }
      console.log('error', error);
    } finally {
      setDrawerProps({ confirmLoading: false });
    }
  }

  /**
   * 生成明细
   */
  async function handleGenerate() {
    try {
      closeModal();
      setDrawerProps({ confirmLoading: true });
      const params: any = {
        isNewRecord: record.value.isNewRecord,
        id: record.value.id,
      };
      const res = await carddYcddrwGenerate(params);
      showMessage(res.message);
      setTimeout(closeDrawer);
      emit('success');
    } catch (error: any) {
      if (error && error.errorFields) {
        showMessage(t('common.validateError'));
      }
      console.log('error', error);
    } finally {
      setDrawerProps({ confirmLoading: false });
    }
  }

  // 计算合计金额
  function computHjje(formModel) {
    let hjje = 0;
    hjje += Number(formModel.ycddrwBrzjje || 0);
    hjje += Number(formModel.ycddrwRzjje || 0);
    hjje += Number(formModel.ycddrwJsje || 0);
    hjje += Number(formModel.ycddrwBrgzje || 0);
    hjje += Number(formModel.ycddrwRgzje || 0);
    hjje += Number(formModel.ycddrwCsje || 0);
    hjje += Number(formModel.ycddrwClcje || 0);
    hjje += Number(formModel.ycddrwMxyf || 0);
    hjje += Number(formModel.ycddrwMxykjyf || 0);
    hjje += Number(formModel.ycddrwMxglf || 0);
    hjje += Number(formModel.ycddrwMxtcf || 0);
    hjje += Number(formModel.ycddrwMxxcf || 0);
    hjje += Number(formModel.ycddrwMxzsf || 0);
    hjje += Number(formModel.ycddrwMxcf || 0);
    hjje += Number(formModel.ycddrwMxqtfy || 0);
    hjje += Number(formModel.ycddrwMxcglyf || 0);
    formModel.ycddrwHjje = hjje.toFixed(2);
  }

  // 子表编辑
  function btEditChange({ column, _record }) {
    if (column.dataIndex === 'btQslm' || column.dataIndex === 'btJslm') {
      const {
        editValueRefs: { btSjgl, btQslm, btJslm },
      } = _record;
      if (btQslm.value && btJslm.value) {
        btSjgl.value = Number(btJslm.value) - Number(btQslm.value);
      } else {
        btSjgl.value = '';
      }
      syncYyglsFromBtSjgl();
    }

    // 直接编辑“实际公里”时也触发联动，并且record.value.ycddrwRwzt == '6' && record.value.basCar?.xnyqc == 0
    console.log('btEditChange', record);
    if (column.dataIndex === 'btSjgl' && record.value.ycddrwRwzt == '6' && record.value.basCar?.xnyqc == 0) {
      syncYyglsFromBtSjgl();
    }
  }

  // 汇总所有行的“实际公里”，赋值到“用油公里数”
  function syncYyglsFromBtSjgl() {
    let total = 0;
    for (const row of carddYcddrwBtTable.getDataSource()) {
      const v = row?.editValueRefs?.btSjgl;
      const num = v ? Number(unref(v)) : Number(row?.btSjgl ?? 0);
      if (!isNaN(num)) total += num;
    }
    setFieldsValue({ ycddrwYygls: total ? Number(total) : '' });
  }

  // 计算子表金额
  function jjEditChange({ column, record }) {
    // 当同一行的单价或者数量发生变化时，更新合计金额（三个数据均为当前行编辑组件的值）
    if (column.dataIndex === 'ryrwjjXd' || column.dataIndex === 'ryrwjjXdsl') {
      const {
        editValueRefs: { ryrwjjXdhj, ryrwjjXd, ryrwjjXdsl },
      } = record;
      ryrwjjXdhj.value = (unref(ryrwjjXd) * unref(ryrwjjXdsl)).toFixed(2);
    }
    if (column.dataIndex === 'ryrwjjBt' || column.dataIndex === 'ryrwjjBtsl') {
      const {
        editValueRefs: { ryrwjjBthj, ryrwjjBt, ryrwjjBtsl },
      } = record;
      ryrwjjBthj.value = (unref(ryrwjjBt) * unref(ryrwjjBtsl)).toFixed(2);
    }
    if (column.dataIndex === 'ryrwjjQt' || column.dataIndex === 'ryrwjjQtsl') {
      const {
        editValueRefs: { ryrwjjQthj, ryrwjjQt, ryrwjjQtsl },
      } = record;
      ryrwjjQthj.value = (unref(ryrwjjQt) * unref(ryrwjjQtsl)).toFixed(2);
    }
    if (column.dataIndex === 'ryrwjjCs' || column.dataIndex === 'ryrwjjCsdj') {
      const {
        editValueRefs: { ryrwjjCshj, ryrwjjCs, ryrwjjCsdj },
      } = record;
      ryrwjjCshj.value = (unref(ryrwjjCs) * unref(ryrwjjCsdj)).toFixed(2);
    }
    if (column.dataIndex === 'ryrwjjCgl' || column.dataIndex === 'ryrwjjCgldj') {
      const {
        editValueRefs: { ryrwjjCglhj, ryrwjjCgl, ryrwjjCgldj },
      } = record;
      ryrwjjCglhj.value = (unref(ryrwjjCgl) * unref(ryrwjjCgldj)).toFixed(2);
    }
    if (column.dataIndex === 'ryrwjjDd' || column.dataIndex === 'ryrwjjDdsl') {
      const {
        editValueRefs: { ryrwjjDdhj, ryrwjjDd, ryrwjjDdsl },
      } = record;
      ryrwjjDdhj.value = (unref(ryrwjjDd) * unref(ryrwjjDdsl)).toFixed(2);
    }
    if (column.dataIndex !== 'ryrwjjZhj' && column.dataIndex !== 'ryrwjjBz') {
      console.log('jjEditChange', column, record);
      // 计算总金额
      const {
        editValueRefs: {
          ryrwjjZhj,
          ryrwjjXdhj,
          ryrwjjBthj,
          ryrwjjQthj,
          ryrwjjCshj,
          ryrwjjCglhj,
          ryrwjjDdhj,
          ryrwjjTcf,
          ryrwjjXcf,
          ryrwjjCf,
          ryrwjjCdf,
          ryrwjjQtfy,
        },
      } = record;
      const total =
        Number(unref(ryrwjjXdhj)) +
        Number(unref(ryrwjjBthj)) +
        Number(unref(ryrwjjQthj)) +
        Number(unref(ryrwjjCshj)) +
        Number(unref(ryrwjjCglhj)) +
        Number(unref(ryrwjjDdhj)) +
        Number(unref(ryrwjjTcf)) +
        Number(unref(ryrwjjXcf)) +
        Number(unref(ryrwjjCf)) +
        Number(unref(ryrwjjCdf)) +
        Number(unref(ryrwjjQtfy));
      ryrwjjZhj.value = Number(total).toFixed(2);
    }
  }

  // 计算外调费用合计
  function computWdfyHj(formModel) {
    let hj = 0;
    hj += Number(formModel.ycddrwZccglxj || 0);
    hj += Number(formModel.ycddrwZccsxj || 0);
    hj += Number(formModel.ycddrwZcglf || 0);
    hj += Number(formModel.ycddrwZctcf || 0);
    hj += Number(formModel.ycddrwZccf || 0);
    hj += Number(formModel.ycddrwZczj || 0);
    // hj += Number(formModel.ycddrwZcxj || 0);
    // hj += Number(formModel.ycddrwZcrgf || 0);
    // hj += Number(formModel.ycddrwZcsl || 0);
    formModel.ycddrwZcxj = hj.toFixed(2);
  }
</script>
